﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing.Design;
using System.Windows.Forms.Design;
using System.Windows.Forms;
using DevExpress.Utils;

namespace ProgNetComponentsDx.Shortcut.Design
{
    public class ShortcutKeyEditor : UITypeEditor
    {
        IWindowsFormsEditorService edSvc = null;
        
        public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
        {
            return UITypeEditorEditStyle.Modal;
        }

        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            edSvc = provider.GetService<IWindowsFormsEditorService>();
            return FormShortcutEdit.ShowShortcutEditor(edSvc, (value.AsEnum<Keys>(Keys.None)));
        }
    }

    public class KeysTypeConverter : System.Windows.Forms.KeysConverter
    {
        public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context)
        {
            return false;
        }
    }
}
